package com.zk.service.impl;

import com.zk.mapper.ClassesMapper;
import com.zk.mapper.StudentMapper;
import com.zk.pojo.Classes;
import com.zk.pojo.Student;
import com.zk.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@Service
public class StudentServiceImpl implements StudentService {
	@Autowired
	private StudentMapper studentMapper;
	@Autowired
	private ClassesMapper classesMapper;

	//1. 查询所有学生
	@Override
	public List<Student> findAll() {
		List<Student> students = studentMapper.findAll();
		for (Student student : students) {
			Classes classes = classesMapper.findById(student.getCid());
			student.setCname(classes.getCname());
		}
		return students;
	}
}
